package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicWhCheckMissionItemDAO;
import com.cssy.yd.logic.entity.LogicWhCheckMissionItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-29
 */
public class LogicWhCheckMissionItemDAOImpl extends SqlMapClientDaoSupport implements LogicWhCheckMissionItemDAO {

    /**
     * 插入数据
     * @param logicWhCheckMissionItemDO
     * @return 插入数据的主键
     */
    public String insertLogicWhCheckMissionItemDO(LogicWhCheckMissionItemDO logicWhCheckMissionItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicWhCheckMissionItem.insert", logicWhCheckMissionItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWhCheckMissionItemDO
     * @return 查出的记录数
     */
    public Integer countLogicWhCheckMissionItemDOByExample(LogicWhCheckMissionItemDO logicWhCheckMissionItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhCheckMissionItem.countByDOExample", logicWhCheckMissionItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhCheckMissionItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhCheckMissionItemDO(LogicWhCheckMissionItemDO logicWhCheckMissionItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicWhCheckMissionItem.update", logicWhCheckMissionItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhCheckMissionItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhCheckMissionItemDO> findListByExample(LogicWhCheckMissionItemDO logicWhCheckMissionItemDO) throws DataAccessException {
        List<LogicWhCheckMissionItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhCheckMissionItem.findListByDO", logicWhCheckMissionItemDO);
        return list;
    }

    /**
     * 根据主键获取logicWhCheckMissionItemDO
     * @param id
     * @return logicWhCheckMissionItemDO
     */
    public LogicWhCheckMissionItemDO findLogicWhCheckMissionItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhCheckMissionItemDO logicWhCheckMissionItemDO = (LogicWhCheckMissionItemDO) getSqlMapClientTemplate().queryForObject("LogicWhCheckMissionItem.findByPrimaryKey", id);
        return logicWhCheckMissionItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhCheckMissionItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhCheckMissionItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicWhCheckMissionItemDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicWhCheckMissionItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhCheckMissionItem_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhCheckMissionItem_ex.count", scs);
  	      return count;
  	}
	
	@Override
	public List<LogicWhCheckMissionItemDO> findItemByCheckMissionID(String checkMissionID) throws DataAccessException{
		 List<LogicWhCheckMissionItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhCheckMissionItem_ex.findByCheckMissionID", checkMissionID);
	        return list;
	}
   	
	@Override
	public Integer deleteItemByCheckMissionID(String checkMissionID) throws DataAccessException{
		 Integer rows = (Integer)getSqlMapClientTemplate().delete("LogicWhCheckMissionItem_ex.deleteByCheckMissionID", checkMissionID);
	        return rows;
	}
	
}